Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Programmer's Overview / Part 1 - Getting Started With QuickDraw GX
Chapter 2 - A Quick & Easy Sample Program


Rotating the Curve

The third supporting object referenced by your curve shape object is its transform object. The properties of the transform object allow you to specify how to map your shape (for example, move, scale, skew, and rotate).

QuickDraw GX provides a number of functions to make it easy to map your shape. One example is the GXRotateShape function. This function takes these parameters:

Suppose you want to rotate your curve shape around its center. You can use
the GXGetShapeCenter function to find the coordinates that best describe the center of the shape. This function is one of many geometric operations provided by QuickDraw GX.

To find the center of your curve shape, you need to define a point structure to contain the calculated center and then call the GXGetShapeCenter function
to calculate the center point:

gxPoint curveCenter;
GXGetShapeCenter(aCurveShape, 0, &curveCenter);
The GXGetShapeCenter function analyzes the geometry of your curve shape, finds the best center point, and returns the coordinates of the center point
in the curveCenter point structure. (The second parameter specifies which contour you want to find the center of--not very useful in this case, because a curve shape has only one contour. You can use a value of 0 for this parameter to indicate that you want to find the center of the entire shape.)

Once you have found the shape's center, you can rotate the shape around its center using the GXRotateShape function:

GXRotateShape(aCurveShape, ff(45), curveCenter.x, curveCenter.y);
This call to the GXRotateShape function rotates your curve clockwise
45.0 degrees around its center.

Note
The GXRotateShape function can rotate a shape in one
of two ways: by changing the mapping property of the shape's transform object or by changing the geometric points stored in the shape's geometry property. To use
the first method, you must set the map transform shape attribute, which is a flag in the shape attributes property
of your curve shape. You can set this attribute using the GXSetShapeAttributes function. See "Editing Shape Transforms" in Chapter 6, "Handling Graphics,"
for details.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996